// component/work/work.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    bannerList:4,
    bannerIndex:0,
    moduleList:[
      {img:"../../image/6.png",text:"功能A",child:[]},
      {img:"../../image/7.png",text:"功能B",child:[
        {img:"../../image/7.png",text:"功能1"},
        {img:"../../image/7.png",text:"功能2"},
        {img:"../../image/7.png",text:"功能3"},
        {img:"../../image/7.png",text:"功能4"},
        {img:"../../image/7.png",text:"功能5"},
        {img:"../../image/7.png",text:"功能6"},
        {img:"../../image/7.png",text:"功能7"},
        {img:"../../image/7.png",text:"功能8"},
        {img:"../../image/7.png",text:"功能9"},
        {img:"../../image/7.png",text:"功能10"}
      ]},
      {img:"../../image/8.png",text:"功能C",child:[]},
      {img:"../../image/8.png",text:"功能D",child:[]},
      {img:"../../image/9.png",text:"功能E",child:[]},
      {img:"../../image/2.png",text:"功能F",child:[]},
      {img:"../../image/5.png",text:"功能G",child:[]},
      {img:"../../image/2.png",text:"功能H",child:[]},
      {img:"../../image/4.png",text:"功能I",child:[]},
      {img:"../../image/3.png",text:"功能J",child:[]},
    ],
    moduleEmptyList:[],
    submenuList:[],
    submenuTitle:"功能b",
    isShowSubmenu:false
  },
  attached:function(){
    let moduleLength=this.data.moduleList.length;
    let length=parseInt(moduleLength%4)===0?4:parseInt(moduleLength%4);
    let list=[];
    for(let i=0;i<4-length;i++){
      list.push({})
    }
    this.setData({
      moduleEmptyList:list
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    // 轮播改变
    bannerChange(e){
      this.setData({
        bannerIndex:e.detail.current
      })
    },
    // 显示子菜单
    showSubmenu(e){
      let that=this;
      let index=e.currentTarget.dataset.index;
      let child=that.data.moduleList[index].child;
      if(child.length>0){
        that.setData({
          submenuList:child,
          submenuTitle:that.data.moduleList[index].text,
          isShowSubmenu:true
        })
      }
    },
    // 隐藏弹框
    showFrame(){
      this.setData({
        isShowSubmenu:false
      })
    }
  }
})
